﻿<%@ WebHandler Language="C#" Class="VerificationOldUser" %>

using System;
using System.Web;

/// <summary>
/// 关联老用户校验
/// </summary>
public class VerificationOldUser : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string userid = context.Request["userId"];
        string userpwd = context.Request["userPwd"];
        string result = VerificationUser(userid, userpwd);
        context.Response.Write(result);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

    /// <summary>
    /// 验证老用户,通过则加载相关企业信息，并返回XML
    /// </summary>
    /// <param name="userid">用户ID</param>
    /// <param name="pwd">用户密码</param>
    /// <returns></returns>
    public  string  VerificationUser(string userid ,string pwd)
    {
        //Common.Log.LogManage.addLogErr("valide", userid+" "+pwd);
        string strReturn = string.Empty;
        string unitId = string.Empty;
     
        bool isExt = true;
        if (userid != null && pwd != null)
        {
            isExt = ChBusiness.User.UserHandle.CheckEncodePassword(userid, pwd);
            if (isExt == true)
            {
                System.Data.DataTable tempDtUser = ChBusiness.User.UserHandle.GetUser(userid);
                if (tempDtUser.Rows.Count > 0)
                {
                    unitId = tempDtUser.Rows[0]["unitsid"].ToString();
                    if (string.IsNullOrEmpty(tempDtUser.Rows[0]["unitsid"].ToString()))
                    {
                        strReturn = "<?xml version='1.0' encoding='UTF-8'?><operationXml><trans><userVerify>1</userVerify><transXml>";
                        strReturn += "</transXml></trans></operationXml>";

                    }
                    else
                    {
                        System.Data.DataTable tempDtUnit = ChBusiness.User.UserHandle.GetUnitsInfo(unitId);
                        if (tempDtUnit.Rows.Count > 0)
                        {
                            strReturn = "<?xml version='1.0' encoding='UTF-8'?><operationXml><trans><userVerify>1</userVerify><transXml>";
                            strReturn += "<state>" + tempDtUnit.Rows[0]["state"] + "</state>";
                            strReturn += "<id>" + tempDtUnit.Rows[0]["id"] + "</id>";
                            strReturn += "<unitname>" + tempDtUnit.Rows[0]["unitsname"] + "</unitname>";
                            strReturn += "<unitnameold>" + tempDtUnit.Rows[0]["unitnameold"] + "</unitnameold>";
                            strReturn += "<description>" + tempDtUnit.Rows[0]["description1"] + "</description>";
                            strReturn += "<regaddress>" + tempDtUnit.Rows[0]["regaddress"] + "</regaddress>";
                            strReturn += "<regpostcode>" + tempDtUnit.Rows[0]["regpostcode"] + "</regpostcode>";
                            strReturn += "<officeaddress>" + tempDtUnit.Rows[0]["unitsaddress"] + "</officeaddress>";
                            strReturn += "<officepostcode>" + tempDtUnit.Rows[0]["postcode"] + "</officepostcode>"; ;
                            strReturn += "<contact>" + tempDtUnit.Rows[0]["contact"] + "</contact>";
                            strReturn += "<telnumber>" + tempDtUnit.Rows[0]["unitstel"] + "</telnumber>";
                            strReturn += "<mobilenumber>" + tempDtUnit.Rows[0]["mobilenumber"] + "</mobilenumber>";
                            strReturn += "<faxnumber>" + tempDtUnit.Rows[0]["fax"] + "</faxnumber>";
                            strReturn += "<email>" + tempDtUnit.Rows[0]["email"] + "</email>";
                            strReturn += "<createdate>" + tempDtUnit.Rows[0]["createdate"] + "</createdate>";
                            strReturn += "<capitalpercentageofinternal>" + tempDtUnit.Rows[0]["capitalpercentageofinternal"] + "</capitalpercentageofinternal>";
                            strReturn += "<unitmanager>" + tempDtUnit.Rows[0]["unitmanager"] + "</unitmanager>";
                            strReturn += "<surveypersonnelcount>" + tempDtUnit.Rows[0]["surveypersonnelcount"] + "</surveypersonnelcount>";
                            strReturn += "<employeescount>" + tempDtUnit.Rows[0]["employeescount"] + "</employeescount>";
                            strReturn += "<legalpersonname>" + tempDtUnit.Rows[0]["organization"] + "</legalpersonname>";
                            strReturn += "<legalpersoncodeorregcode>" + tempDtUnit.Rows[0]["legalpersoncodeorregcode"] + "</legalpersoncodeorregcode>";
                            strReturn += "<regcapital>" + tempDtUnit.Rows[0]["regcapital"] + "</regcapital>";
                            strReturn += "<independentunitname>" + tempDtUnit.Rows[0]["independentunitname"] + "</independentunitname>";
                            strReturn += "<appendixlist>" + tempDtUnit.Rows[0]["appendixlist"] + "</appendixlist>";
                            strReturn += "<prefecture>" + tempDtUnit.Rows[0]["prefecture"] + "</prefecture>";
                            strReturn += "<capitaltype>" + tempDtUnit.Rows[0]["capitaltype"] + "</capitaltype>";
                            strReturn += "<unittype>" + tempDtUnit.Rows[0]["unittype"] + "</unittype>";
                            strReturn += "<unitproperty>" + tempDtUnit.Rows[0]["unitproperty"] + "</unitproperty>";
                            strReturn += "<unitactiontypebeforeapply>" + tempDtUnit.Rows[0]["unitactiontypebeforeapply"] + "</unitactiontypebeforeapply>";
                            strReturn += "<appendixlist3>" + tempDtUnit.Rows[0]["appendixlist3"] + "</appendixlist3>";
                            strReturn += "<appendixlist4>" + tempDtUnit.Rows[0]["appendixlist4"] + "</appendixlist4>";
                            strReturn += "<appendixlist5>" + tempDtUnit.Rows[0]["appendixlist5"] + "</appendixlist5>";
                            strReturn += "<officearea>" + tempDtUnit.Rows[0]["officearea"] + "</officearea>";
                            strReturn += "<companytype>" + tempDtUnit.Rows[0]["companytype"] + "</companytype>";
                            strReturn += "<firstqualifyedowmleve>" + tempDtUnit.Rows[0]["firstqualifyedowmleve"] + "</firstqualifyedowmleve>";
                            strReturn += "<confidential>" + tempDtUnit.Rows[0]["confidential"] + "</confidential>";
                            strReturn += "<branchdivision>" + tempDtUnit.Rows[0]["branchdivision"] + "</branchdivision>";
                            strReturn += "<legalperson>" + tempDtUnit.Rows[0]["legal"] + "</legalperson>";
                            //strReturn += "<legalpersonname>" + tempDtUnit.Rows[0]["legal"] + "</legalpersonname>";
                            strReturn += "<surveyleveltype>" + tempDtUnit.Rows[0]["surveyleveltype"] + "</surveyleveltype>";
                            strReturn += "<text>" + tempDtUnit.Rows[0]["text"] + "</text>";
                            strReturn += "<validstart>" + tempDtUnit.Rows[0]["validstart"] + "</validstart>";
                            strReturn += "<provinid>" + tempDtUnit.Rows[0]["provinid"] + "</provinid>";
                            strReturn += "<sourceid>" + tempDtUnit.Rows[0]["sourceid"] + "</sourceid>";
                            strReturn += "<datastate>" + tempDtUnit.Rows[0]["datastate"] + "</datastate>";
                            strReturn += "</transXml></trans></operationXml>";
                        }
                    }
                }
            }
            else
            {
                strReturn = "<?xml version='1.0' encoding='UTF-8'?><operationXml><trans><userVerify>0</userVerify><transXml>";
                strReturn += "</transXml></trans></operationXml>";
            }
        }
        return strReturn;

    }
}